home *** CD-ROM | disk | FTP | other *** search
/ Interactive Web Graphics with Shout 3D / Interactive Web Graphics With Shout 3D.iso / mac / Code / Chapter09 / ProcAnimPanel.java < prev    next >
Text File  |  2000-07-05  |  940b  |  61 lines

  1.  
  2.  
  3.  
  4. package applets;
  5.  
  6. import shout3d.*;
  7. import shout3d.core.*;
  8. import shout3d.math.*;
  9.  
  10.  
  11. public class ProcAnimPanel extends Shout3DPanel implements RenderObserver{
  12.     
  13.     
  14.     Transform t;
  15.     float xPos;
  16.  
  17.  
  18.  
  19.  
  20.     public ProcAnimPanel (Shout3DApplet applet){
  21.         super(applet);
  22.     }
  23.     
  24.     
  25.         public void customInitialize() {
  26.         getRenderer().addRenderObserver(this, null);
  27.  
  28.         t = (Transform) getNodeByName("trans");
  29.         xPos = t.translation.getValue()[0];        
  30.     }
  31.  
  32.  
  33.     protected void finalize()  { 
  34.         getRenderer().removeRenderObserver(this);
  35.     }
  36.  
  37.  
  38.  
  39.     public void onPreRender (Renderer r, Object o) {
  40.         
  41.         //movement since previous frame
  42.         //at .5 meter per second.
  43.         float xDelta = .5f/getFramesPerSecond();
  44.         
  45.         //add to current x postion
  46.         xPos = xPos + xDelta;
  47.  
  48.         //update Transform
  49.         t.translation.set1Value(0, xPos);
  50.     
  51.     }
  52.     
  53.  
  54.     public void onPostRender (Renderer r, Object o) {
  55.     
  56.     
  57.     }
  58.  
  59.     
  60.  
  61. } //end of class